import { Suspense, memo } from 'react'
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom'
import { routes } from './router'
import Loading from './components/loading'

export default memo(() => (
	<HashRouter>
		<Suspense fallback={<Loading />}>
			<Switch>
				{routes.map((route) => (
					<Route key={route.path} {...route} />
				))}
				<Route path='/' exact render={() => <Redirect to='/good/detail' />} />
				<Redirect to='/404' />
			</Switch>
		</Suspense>
	</HashRouter>
))
